package com.cakeclient.Model;


import android.content.Context;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

public class Basket {

    private List<ProductType> products = new ArrayList<ProductType>();
    private List<MenuType> menus = new ArrayList<MenuType>();

    public Basket() {

    }

    public List<MenuType> getMenus() {
        return menus;
    }

    public void setMenus(List<MenuType> menus) {
        this.menus = menus;
    }

    public List<ProductType> getProducts() {
        return products;
    }

    public void setProducts(List<ProductType> products) {
        this.products = products;
    }
    
    public Order toOrder(Client client,Address delivryAddress,Context context){
        Order newOrder = new Order(client,delivryAddress);    
        newOrder.setOrderDate(new Date());
        for(ProductType product : products){
            UnitarySale unitarySale = new UnitarySale(product.getLocalPrice(Store.getLocalStore(context)),product.getVat(),product);
            newOrder.getUnitarySaleList().add(unitarySale);
        }
        newOrder.saveToDatabase(context);
        return newOrder;
    }
}
